package com.gykj.tap.schedule;

import lombok.extern.slf4j.Slf4j;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 使用Spring Task 简单的定时任务(单线程)，添加 一个配置类+ @Async 可确保每个任务都是独立的线程
 * @author rohto
 * 
 */
//@Component
@Slf4j
@Async //
public class ScheduledService {
//	@Scheduled(cron = "*/5 * * * * ?")
	@Scheduled(cron = "${spring.schedule.jobs.cron}")
	public void scheduled() {
		
		log.info("=====>>>>>使用cron  {}", System.currentTimeMillis());
	}

	@Scheduled(fixedRate = 5000)
	public void scheduled1() {
		log.info("=====>>>>>使用fixedRate{}", System.currentTimeMillis());
	}

	@Scheduled(fixedDelay = 5000)
	public void scheduled2() {
		log.info("=====>>>>>fixedDelay{}", System.currentTimeMillis());
	}
}
